package ffmpeg;


import enums.FFmpegCodeEnum;
import exception.FFmpegException;

import java.util.concurrent.ConcurrentHashMap;

public class ProcessMap {

    public static final ConcurrentHashMap<Integer, FFmpeg> processManagerHashMap = new ConcurrentHashMap<>();

    /**
     * kill 线程
     *
     * @param uniqueCode : hashcode
     */
    public static void destroy(Integer uniqueCode) {
        if (!processManagerHashMap.containsKey(uniqueCode)) {
            throw new FFmpegException(FFmpegCodeEnum.UNIQUE_CODE_NONE);
        }
        FFmpeg fFmpeg = processManagerHashMap.get(uniqueCode);
        fFmpeg.getProcess().destroy();
        processManagerHashMap.remove(uniqueCode);
    }

}
